package com.fanrui.code.util;

import com.fanrui.code.dao.PlayerLogDao;
import com.fanrui.code.entity.PlayerLog;
import com.fanrui.code.player.Player;

public class PlayerLogUtil {

	public enum PlayerOpertionType {
		/** 每日vip补给金额 **/
		VipSupply(1),
		
		/** 轮盘抽奖 **/
		Routtle(2),
		ChangeClubName(3),
		/** 创建好友房 **/
		CreateFriendRoom(4);

		private int value;

		private PlayerOpertionType(int value) {
			this.value = value;
		}

		public int getValue() {
			return value;
		}

		public void setValue(int value) {
			this.value = value;
		}

	}

	/**
	 * 玩家操作经济变化日志记录
	 * @param player
	 * @param type
	 * @param intValue1
	 * @param intValue2
	 * @param intValue3
	 * @param longValue1
	 * @param longValue2
	 * @param strValue1
	 * @param strValue2
	 * @param data 在操作之前记录
	 */
	public static void log(Player player, PlayerOpertionType type, Integer intValue1, Integer intValue2, Integer intValue3,
			Long longValue1, Long longValue2, String strValue1, String strValue2, PlayerData data) {
		log(PlayerLogBuilder.createBuilder().setOperationType(type).setOperationIntValue1(intValue1)
				.setOperationIntValue2(intValue2).setOperationIntValue3(intValue3).setOperationLongValue1(longValue1)
				.setOperationLongValue2(longValue2).setOperationStrValue1(strValue1).setOperationStrValue2(strValue2)
				.setBeforePlayerData(data).setAfterPlayerData(player).buildLog());
	}
	public static void log(Player player, PlayerOpertionType type, int intValue1, String strValue1, PlayerData data) {
		log(PlayerLogBuilder.createBuilder().setOperationType(type).setOperationIntValue1(intValue1)
				.setOperationStrValue5(strValue1).setPlayer(player).setPlayerData(data).buildLog());
	}
	/**
	 * 持久层保存数据
	 * @param log
	 */
	public static void log(PlayerLog log) {
		PlayerLogDao.getInstance().save(log);
	}

}
